package com.opages.transaction.message.api;


import com.opages.transaction.message.common.domain.HttpResult;
import com.opages.transaction.message.common.exception.MessageException;
import com.opages.transaction.message.model.TransactionMessage;
import io.swagger.annotations.Api;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping(path = "/transactionMessage")
@Api(tags = "事务消息管理")
@FeignClient(contextId = "com.opages.transaction.message.api.TransactionMessageApi",
		name = "${com.opages.transaction.message.api.TransactionMessageApi.name:transaction-message}",
		url = "${com.opages.transaction.message.api.TransactionMessageApi.url:}")
public interface TransactionMessageApi {
	/**
	 * 预存储消息.
	 */
	@PostMapping("/waitingCoonfirm")
	public HttpResult saveMessageWaitingConfirm(@RequestBody TransactionMessage rpTransactionMessage) throws MessageException;
	/**
	 * 确认并发送消息.
	 */
	@PutMapping("/confirmSend/${messageId}")
	public HttpResult confirmAndSendMessage(@PathVariable("messageId") String messageId) throws MessageException;
	/**
	 * 存储并发送消息.
	 */
	@PostMapping("/saveSend")
	public HttpResult saveAndSendMessage(@RequestBody TransactionMessage rpTransactionMessage) throws MessageException;
	/**
	 * 直接发送消息.
	 */
	@PostMapping("/directSend")
	public HttpResult directSendMessage(@RequestBody TransactionMessage rpTransactionMessage) throws MessageException;
	/**
	 * 重发消息.
	 */
	@PostMapping("/updateResend")
	public HttpResult reSendMessage(@RequestBody TransactionMessage rpTransactionMessage) throws MessageException;
	/**
	 * 根据messageId重发某条消息.
	 */
	@GetMapping("/resendMsg/${messageId}")
	public HttpResult reSendMessageByMessageId(@PathVariable("messageId") String messageId) throws MessageException;
	/**
	 * 将消息标记为死亡消息.
	 */
	@GetMapping("/areadlyDead/${messageId}")
	public HttpResult setMessageToAreadlyDead(@PathVariable("messageId") String messageId) throws MessageException;
	/**
	 * 根据消息ID获取消息
	 */
	@GetMapping("/get/${messageId}")
	public TransactionMessage getMessageByMessageId(@PathVariable("messageId") String messageId) throws MessageException;
	/**
	 * 根据消息ID删除消息
	 */
	@DeleteMapping("/del/${messageId}")
	public HttpResult deleteMessageByMessageId(@PathVariable("messageId") String messageId) throws MessageException;
	/**
	 * 重发某个消息队列中的全部已死亡的消息.
	 */
	@GetMapping("/sendBath/${queueName}/${batchSize}")
	public HttpResult reSendAllDeadMessageByQueueName(@PathVariable("queueName") String queueName, @PathVariable("batchSize") int batchSize) throws MessageException;
    /**
     * 获取分页中的list
     **/
	@GetMapping("/findList/${pageSize}/${pageNum}")
    public List<TransactionMessage> findList(@PathVariable("pageNum") int pageNum,@PathVariable("pageSize") int pageSize,@RequestBody TransactionMessage message);
}
